home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / Range.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  101 lines

  1. /* Range.c  -- implementation of NIHCL class Range
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.         C. J. Eppich
  12.     Computer Systems Laboratory
  13.     Division of Computer Research and Technology
  14.     National Institutes of Health
  15.     Bethesda, Maryland 20892
  16.     Phone: (301) 496-5361
  17.     uucp: uunet!nih-csl!kgorlen
  18.     Internet: kgorlen@alw.nih.gov
  19.     September, 1987
  20.  
  21. Function:
  22.  
  23. Class Range implements an ordered pair of ints that can be used to indicate
  24. a segment of some array (possibly a character string or vector).
  25.  
  26. $Log:    Range.c,v $
  27.  * Revision 3.0  90/05/20  00:20:55  kgorlen
  28.  * Release for 1st edition.
  29.  * 
  30. */
  31.  
  32. #include "Range.h"
  33. #include "nihclIO.h"
  34.  
  35. #define    THIS    Range
  36. #define    BASE    Object
  37. #define BASE_CLASSES BASE::desc()
  38. #define MEMBER_CLASSES
  39. #define VIRTUAL_BASE_CLASSES Object::desc()
  40.  
  41. DEFINE_CLASS(Range,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Range.c,v 3.0 90/05/20 00:20:55 kgorlen Rel $",NULL,NULL);
  42.  
  43. //======= Protected member functions:
  44.  
  45. Range::Range(OIOin& strm)
  46.     : BASE(strm)
  47. {
  48.     strm >> first >> len;
  49. }
  50.  
  51. void Range::storer(OIOout& strm) const
  52. {
  53.     BASE::storer(strm);
  54.     strm << first << len;
  55. }
  56.  
  57. Range::Range(OIOifd& fd)
  58.     : BASE(fd)
  59. {
  60.     fd >> first >> len;
  61. }
  62.  
  63. void Range::storer(OIOofd& fd) const
  64. {
  65.     BASE::storer(fd);
  66.     fd << first << len;
  67. }
  68.  
  69.  
  70. //======= Public member functions:
  71.  
  72. void Range::deepenShallowCopy()  {}
  73.  
  74. unsigned Range::hash() const
  75. {
  76.     return (first^len);
  77. }
  78.  
  79. bool Range::isEqual(const Object& p) const
  80. // Test two objects for equality
  81. {
  82.     return p.isSpecies(classDesc) && *this==castdown(p);
  83. }
  84.  
  85. void Range::printOn(ostream& strm) const
  86. {
  87.     strm << first << ':' << len;
  88. }
  89.  
  90. const Class* Range::species() const
  91. // Return a pointer to the descriptor of the species of this class
  92. {
  93.     return Range::desc();
  94. }
  95.  
  96. int Range::compare(const Object&) const
  97. {
  98.     shouldNotImplement("compare");
  99.     return 0;
  100. }
  101.